#! /usr/bin/python

import sys
import os

if __name__ == "__main__":
	if (len(sys.argv) != 2):
		print sys.argv[0] + " trace"
		exit(-1)

	fo = open(sys.argv[1])
	als = fo.readlines()
	memSize = 0
	memGpuTime = 0
	totalGpuTime = 0
	totalCpuTime = 0

	for line in als:
		if len(line.strip().split("gputime=")) <2:
			continue

		tmp = line
		tmp = tmp.strip().split("gputime=")[1]
		tmp = tmp.split("[")[1]
		tmp = tmp.split("]")[0]
		totalGpuTime += float(tmp)

		tmp = line
		tmp = tmp.strip().split("cputime=")[1]
		tmp = tmp.split("[")[1]
		tmp = tmp.split("]")[0]
		totalCpuTime += float(tmp)

		if len(line.strip().split("memtransfersize=")) <2:
			continue

		tmp = line
		tmp = tmp.strip().split("memtransfersize=")[1]
		tmp = tmp.split("[")[1]
		tmp = tmp.split("]")[0]
		memSize += int(tmp)

		tmp = line
		tmp = tmp.strip().split("gputime=")[1]
		tmp = tmp.split("[")[1]
		tmp = tmp.split("]")[0]
		memGpuTime += float(tmp)

	print "memSize", memSize
	print "memGpuTime", memGpuTime
	print "totalGpuTime",totalGpuTime
	print "totalCpuTime",totalCpuTime

